  $(function(){
		$("#addMagazine").click(function(){
			 var reg=/^\+?[1-9][0-9]*$/;
			 var periods = $('#periods').val();
			 var detail = $('#detail').val();
			 var pdfurl = $('#pdfurl').val();
			 var imgurl = $('#imgurl').val();
			 var date = $('#uptime').val();
		     
			 if (pdfurl== ''||pdfurl==null) { 
				 alert("杂志电子版尚未上传结束，请耐心等待"); 
				 return false;
			 }
		     
			 if(!reg.test(periods)){
			        alert("期数只能输入数字");
			        return false;
			    }
			 var magazine = {"periods":periods, "detail":detail,"pdfurl":pdfurl,"imgurl":imgurl,"date":date};
			  $.ajax({ 
                    type : "post",                                             
                    url : "addMagazine",
                    dataType:"json", 
                    contentType:"application/json",
                    data:JSON.stringify(magazine),
                    success : function(data) {   	
				    alert(data.message);
				    var index = parent.layer.getFrameIndex(window.name);
				    window.parent.location.reload();
				    // 关闭当前frame
				    parent.layer.close(index);
                     
                       
                    },
                    error : function() {
                        alert("添加失败");
                    }
                });	
		});
		});
  
  $(function(){
		$("#editMagazine").click(function(){
			 var reg=/^\+?[1-9][0-9]*$/;
			 var id = $('#id').val();
			 var periods = $('#periods').val();
			 var detail = $('#detail').val();
			 var pdfurl = $('#pdfurl').val();
			 var imgurl = $('#imgurl').val();

			 if(!reg.test(periods)){
			        alert("期数只能输入数字");
			        return false;
			    }
			 var magazine = {"periods":periods, "detail":detail,"pdfurl":pdfurl,"imgurl":imgurl,"id":id};
			  $.ajax({ 
                  type : "post",                                             
                  url : "updataMagazine",
                  dataType:"json", 
                  contentType:"application/json",
                  data:JSON.stringify(magazine),
                  success : function(data) {   	
				    alert(data.message);
				    var index = parent.layer.getFrameIndex(window.name);
				    window.parent.location.reload();
				    // 关闭当前frame
				    parent.layer.close(index);
                   
                     
                  },
                  error : function() {
                      alert("添加失败");
                  }
              });	
		});
		});
  
  $(function(){
		$("#addMagazineNews").click(function(){
			 var reg=/^\+?[1-9][0-9]*$/;
			 var title = $('#title').val();
			 var featureName = $('#featureName').val();
			 var periodical = $('#periodical').val();
			 var detail =$('#editor').val();
		
			 if(!reg.test(periodical)){
			        alert("期数只能输入数字");
			        return false;
			    }
			 var magazinenews = {"title":title, "featureName":featureName,"periodical":periodical,"detail":detail};
			  $.ajax({ 
                  type : "post",                                             
                  url : "addMagazineNews",
                  dataType:"json", 
                  contentType:"application/json",
                  data:JSON.stringify(magazinenews),
                  success : function(data) {   	
				    alert(data.message);
				    var index = parent.layer.getFrameIndex(window.name);
				    window.parent.location.reload();
				    // 关闭当前frame
				    parent.layer.close(index);
                   
                     
                  },
                  error : function() {
                      alert("添加失败");
                  }
              });	
		});
		});
  
  $(function(){
		$("#updateMagazineNews").click(function(){
			
			 var title = $('#title').val();
			 var featureName = $('#featureName').val();
		
			 var detail =$('#editor').val();
			 var id=$('#id').val();
		
			
			 var magazinenews = {"title":title, "featureName":featureName,"detail":detail,"id":id};
			  $.ajax({ 
                type : "post",                                             
                url : "updataMagazineNews",
                dataType:"json", 
                contentType:"application/json",
                data:JSON.stringify(magazinenews),
                success : function(data) {   	
				    alert(data.message);
				    var index = parent.layer.getFrameIndex(window.name);
				    window.parent.location.reload();
				    // 关闭当前frame
				    parent.layer.close(index);
                 
                   
                },
                error : function() {
                    alert("添加失败");
                }
            });	
		});
		});
  
 